package utils

import "time"

func StatCycleDuration(cycle int) time.Duration {
	switch cycle {
	case 1:
		//return statisItem{Key: 1, Value: "10分钟", Corn: TenMinCorn}
		return time.Minute * 10
	case 2:
		//return statisItem{Key: 2, Value: "半小时", Corn: HalfHourCorn}
		return time.Minute * 30
	case 3:
		//return statisItem{Key: 3, Value: "1小时", Corn: OneHourCorn}
		return time.Hour * 1
	case 4:
		//return statisItem{Key: 4, Value: "12小时", Corn: TwelveHourCorn}
		return time.Hour * 12
	case 5:
		//return statisItem{Key: 5, Value: "1天", Corn: OneDayCorn}
		return time.Hour * 24
	case 6:
		//return statisItem{Key: 6, Value: "1周", Corn: OneWeekCorn}
		return time.Hour * 24 * 7
	case 7:
		//return statisItem{Key: 7, Value: "1月", Corn: OneMonthCorn}
		return time.Hour * 24 * 30
	default:
		return time.Hour * 1
	}
}

// 实现枚举例子
type StatisValueTypeCode int

const (
	AvgValue StatisValueTypeCode = iota + 1
	SumValue
	DiffValue
	MaxValue
	MinValue
	StartValue
	EndValue
	CountValue
	DistinctCountValue
)

//自定义返回枚举类型
type statisValueType struct {
	Key   int
	Value string
}

func (it StatisValueTypeCode) Get() statisValueType {
	switch it {
	case AvgValue:
		return statisValueType{Key: 1, Value: "平均值"}
	case SumValue:
		return statisValueType{Key: 2, Value: "总数"}
	case DiffValue:
		return statisValueType{Key: 3, Value: "差值"}
	case MaxValue:
		return statisValueType{Key: 4, Value: "最大值"}
	case MinValue:
		return statisValueType{Key: 5, Value: "最小值"}
	case StartValue:
		return statisValueType{Key: 6, Value: "开始值"}
	case EndValue:
		return statisValueType{Key: 7, Value: "结尾值"}
	case CountValue:
		return statisValueType{Key: 8, Value: "计数"}
	case DistinctCountValue:
		return statisValueType{Key: 9, Value: "去重计数"}
	default:
		return statisValueType{}
	}
}

func GetValueType(valueType int) statisValueType {
	switch valueType {
	case AvgValue.Get().Key:
		return AvgValue.Get()
	case SumValue.Get().Key:
		return SumValue.Get()
	case DiffValue.Get().Key:
		return DiffValue.Get()
	case MaxValue.Get().Key:
		return MaxValue.Get()
	case MinValue.Get().Key:
		return MinValue.Get()
	case StartValue.Get().Key:
		return StartValue.Get()
	case EndValue.Get().Key:
		return EndValue.Get()
	case CountValue.Get().Key:
		return CountValue.Get()
	case DistinctCountValue.Get().Key:
		return DistinctCountValue.Get()
	default:
		return statisValueType{}
	}
}
